<head>
    <meta charset="UTF-8">
<title>算法提高 冒泡排序计数</title>
<link rel="stylesheet" href="../css/main.css">
</head>
 <div>考虑冒泡排序的一种实现。</div>
<div>bubble-sort (A[], n)</div>
<div>&gt; round = 0</div>
<div>&gt; while A is not sorted</div>
<div>&gt; &gt; round := round + 1</div>
<div>&gt; &gt; for i := 1 to n - 1</div>
<div>&gt; &gt; &gt; if (A[i] &gt; A[i + 1])</div>
<div>&gt; &gt; &gt; &gt; swap(A[i], A[i + 1])</div>
<div>求1 .. n的排列中，有多少个排列使得A被扫描了K遍，亦即算法结束时round == K。</div>
<div>&nbsp;</div>
<div>答案模20100713输出。</div>
<div>&nbsp;</div>
<div>输入格式</div>
<div>&nbsp;</div>
<div>输入包含多组数据。每组数据为一行两个整数N，K。</div>
<div>&nbsp;</div>
<div>输出格式</div>
<div>&nbsp;</div>
<div>对每组数据，输出一行一个整数表示答案。</div>
<div>&nbsp;</div>
<div>样例输入</div>
<div>&nbsp;</div>
<div>3</div>
<div>3 0</div>
<div>3 1</div>
<div>3 2</div>
<div>&nbsp;</div>
<div>样例输出</div>
<div>&nbsp;</div>
<div>1</div>
<div>3</div>
<div>2</div>
<div>&nbsp;</div>
<div>数据规模和约定</div>
<div>&nbsp;</div>
<div>T &lt;= 10 ^ 5。 &nbsp;</div>
<div>1 &lt;= K &lt; N &lt; 10 ^ 6。</div>
<div>&nbsp;</div>